﻿$(function () {

    GetTrips();

    function GetTrips() {

        var serviceUrl = "http://" + document.location.host + "/ServiceTravelAgency.svc/GetTrips";

        $.getJSON(serviceUrl, function (data) {

            var content = $(".content");
            var html = "";
            for (var trip in data) {
                if (trip / 4 == 0) {
                    html += "<div class='row'>"
                }
                html += "<div class='cell'><div class='trip' id='" + data[trip].Id + "' class='question"
                "' >" + data[poll].pQuestion + "<ul class='answerList'>";
                html += "<img src='" + "http://" + document.location.host + "/ServiceTravelAgency.svc/GetGetImage" + data[trip].PhotoId + "' / alt='no image available'>";

                if ((poll % 3) == 2) {
                    html += "</div>"
                }
                if (poll == data.length - 1) {

                    html += "<div class='clearer'></div>";
                }

            }
            content.html(html);
        });
    }
});